package com.CST.controller.ys;

import com.CST.common.api.ResultObject;
import com.CST.dto.ys.YsOrganizationDTO;
import com.CST.entity.ys.YsOrganization;
import com.CST.service.ys.YsOrganizationService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 预算编制数据
 *
 * @author cw
 * @since 2023-05-15
 */
@RestController
@RequestMapping("/ysOrganization")
@Api(tags="预算编制数据")
public class YsOrganizationController {

    @Autowired
    private YsOrganizationService targetService;

    @ApiOperation("新增编制年份")
    @GetMapping("/insertOrganization/{year}")
    public ResultObject<Boolean> insertOrganization(@PathVariable Integer year){
        return ResultObject.success(targetService.insertOrganization(year));
    }

    @ApiOperation("取消发布")
    @GetMapping("/cancelRelease/{id}")
    public ResultObject<Boolean> cancelRelease(@PathVariable Integer id){
        return ResultObject.success(targetService.cancelRelease(id));
    }

    @ApiOperation("完成编制")
    @GetMapping("/finishOrganization/{year}")
    public ResultObject<Boolean> finishOrganization(@PathVariable Integer year){
        return ResultObject.success(targetService.finishOrganization(year));
    }

    @ApiOperation("发布数据")
    @GetMapping("/releaseOrganization/{year}")
    public ResultObject<Boolean> releaseOrganizationData(@PathVariable Integer year){
        return ResultObject.success(targetService.releaseOrganizationData(year));
    }

    @ApiOperation("分页查询")
    @PostMapping("/getOrganizationList")
    public ResultObject<PageInfo<YsOrganization>> getOrganizationList(@RequestBody YsOrganizationDTO dto){
        return ResultObject.success(targetService.getOrganizationList(dto));
    }
}
